import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 三石
 * Date: 2022-05-17
 * Time: 22:32
 */
class student2 {
    public String name;
    public double score;
    public int age;
    public String classes = "105";

    public student2(String name, double score, int age) {
        this.name = name;
        this.score = score;
        this.age = age;
    }
}
public class Class1 {

    public static void main19(String[] args) {
        student2 student2 =new student2("zhangsan",50.0,20);
        System.out.println(student2.age+" "+ student2.score+ student2.name);
        System.out.println(student2.classes);
    }

    /**
     * 返回坐标
     * @param args
     */
    public static void main18(String[] args) {
        int []arr={2,7,11,15};
        int target=9;
        for (int i = 0; i <=arr.length/2; i++) {
            for (int j = i; j <arr.length; j++) {
                if (arr[i]+arr[j]==target){
                    System.out.println("["+i+","+j+"]");

                }
            }
        }
    }

    /**
     *  把一个整型数组转换成字符串
     * @param arr
     * @return
     */
    public static String toString(int []arr){
        String ret="[";
        for (int i = 0; i <arr.length; i++) {
            ret+=arr[i];
            if (i!=arr.length-1){
                ret+=",";
            }
        }
        ret+="]";
        return ret;
    }
    public static void main17(String[] args) {
        int []arr={1,2,3,4,5};
        String x=toString(arr);
        System.out.println(x);
    }

    /**
     * 拷贝一个数组
     * @param arr
     */
    public static void copyOf(int []arr){
        int []arr1=new int[arr.length];
        for (int i = 0; i <arr.length; i++) {
            arr1[i]=arr[i];
        }
        System.out.println("拷贝得到的数组为：");
        for (int x:arr1) {
            System.out.print(x+" ");
        }
    }
    public static void main16(String[] args) {
        int []arr={1,2,3,4,5,6};
        copyOf(arr);
    }


    /**
     * 判断一个数组是不是有序数组
     * @param args
     */
    public static void main15(String[] args) {
        int []array={1,2,3,4,5,7,6,8,9,10};
        for (int x:array) {
            System.out.print(x+" ");
        }
        for (int i = 0; i <array.length-1; i++) {
            int flag = 0;
            for (int j = 0; j < array.length - 1 - i; j++) {
                if (array[j] > array[j + 1]) {
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                    flag = 1;
                }
            }

            if(flag != 0) {
                System.out.println("不是有序数组");
                break;
            } else {
                System.out.println("是有序数组");
                break;
            }
        }
    }

    /**
     * 冒泡排序
     * @param args
     */
    public static void main14(String[] args) {
        int []array={1,9,3,6,5,4,8,7,2,10};
        System.out.println("排序之前：");

        for (int x:array) {
            System.out.print(x+" ");
        }
        for (int i = 0; i <array.length-1; i++) {
            for (int j = 0; j <array.length-1-i ; j++) {
                if (array[j]>array[j+1]){
                    int temp=array[j];
                    array[j]=array[j+1];
                    array[j+1]=temp;
                }
            }
        }
        System.out.println();
        System.out.println("排序之后：");
        for (int x:array) {
            System.out.print(x+" ");
        }
    }


    /**
     * 寻找关键字
     * @param key
     * @param arr
     * @return
     */
    public static int findkey(int key,int[] arr){
        int left=0;
        int right=arr.length-1;
        while (left<=right){
            int mid=(right+left)/2;
            if(arr[mid]==key){
                return mid;
            }else if(key<arr[mid]){
                right=mid-1;
            }else {
                left=mid+1;
            }
        }
        return 0;
    }

    public static void main13(String[] args) {
        int []arr={1,2,3,4,5,6,7,8,9,10};
        int ret=findkey(3,arr);
        System.out.println("找到了下标为："+ret);
    }


    /**
     * 创建一个数组，并赋值
     * @param args
     */
    public static void main12(String[] args) {
        int[] arr=new int[100];
        int j=1;
        for (int i = 0; i <arr.length; i++) {
            arr[i]=j;
            j++;
        }
        for(int x:arr){
            System.out.print(x+" ");
        }
    }
    public static void trans(int []array){
        for (int i = 0; i <array.length ; i++) {
            array[i]*=2;
        }
        for (int x:array){
            System.out.print(x+" ");
        }
    }

    public static void main11(String[] args) {
        int []array={1,2,3};
        trans(array);
    }


    public static void fun1(int x,int y){
        int t=x;
        x=y;
        y=t;
    }
    public static void main10(String[] args) {
        int x=10;
        int y=20;
        System.out.println(x);
        System.out.println(y);
    }


    /**
     * 计算位数
     * @param args
     */
    public static void main9(String[] args) {
        int count=0;
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        if(a<0){
            System.out.println(a);
        }else {
            while (a!=0){
                count++;
                a=a/10;
            }
            System.out.println("位数为："+count);
        }

    }



    /**
     * 递归求n的阶乘
     */
    public static int fabi(int n){
        if(n==1){
            return 1;
        }
        return n*fabi(n-1);
    }

    public static void main8(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        System.out.println(n+"的阶乘为："+fabi(n));
    }



    /**
     * 递归求和
     */
    public static int Sum(int n){
        if(n==1){
            return 1;
        }
        return n+Sum(n-1);
    }

    public static void main6(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int ret=Sum(n);
        System.out.println("1到"+n+"的和为："+ret);
    }



    /**
     * 递归打印数字的每一位
     *
     * @param
     */
    public static void print(int n) {
        if (n < 10) {
            System.out.print(n+" ");
        } else {
            print(n / 10);
            System.out.print(n % 10+" ");
        }
    }
    public static void main4(String[]args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        print(n);
    }



    public static int Fun2 ( int n){
        if (n == 1 || n == 2) {
            return 1;
        }
        int ret = Fun2(n - 1) + Fun2(n - 2);
        return ret;
    }
    public static void main3 (String[]args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println("斐波那契数列的第" + n + "项为：" + Fun2(n));
    }


    /**
     * 递归求1+2+..+10
     * @param n
     * @return
     */
    public static int Fun1 ( int n){
        int sum = 0;
        if (n < 10) {
            return n;
        }
        sum += n % 10 + Fun1(n / 10);
        return sum;
    }

    public static void main2 (String[]args){
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入数字n=");
        int n = scanner.nextInt();
        int ret = Fun1(n);
        System.out.println(ret);

    }


    /**
     * 递归求斐波那契数
     * @param n
     * @return
     */
    public static int fbi ( int n){
        if (n == 1 || n == 2) {
            return 1;
        }
        int f1 = 1, f2 = 1, f3 = 0;
        for (int i = 3; i <= n; i++) {
            f3 = f1 + f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }
    public static void main1 (String[]args){
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入数字n=");
        int n = scanner.nextInt();
        int ret = fbi(n);
        System.out.println("第" + n + "项斐波那契数为：" + ret);
    }
}

